package com.ruirenyun.util.common;

import org.springframework.context.ApplicationContext;

public class BeanUtil {
    //将管理上下文的applicationContext设置成静态变量，供全局调用
    private static ApplicationContext applicationContext;

    private BeanUtil() {
    }

    //定义一个获取已经实例化bean的方法
    public static <T> T getBean(Class<T> c) {
        return applicationContext.getBean(c);
    }

    public static void setApplicationContext(ApplicationContext applicationContext) {
        BeanUtil.applicationContext = applicationContext;
    }
}
